Skip to content

fix(deps): update module github.com/charmbracelet/lipgloss to v2 - #2769

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/github.com-charmbracelet-lipgloss-2.x
Open

fix(deps): update module github.com/charmbracelet/lipgloss to v2#2769
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/github.com-charmbracelet-lipgloss-2.x

Conversation

@renovate

@renovate renovate Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Change Age Confidence
github.com/charmbracelet/lipgloss v1.1.0v2.0.5 age confidence

Release Notes

charmbracelet/lipgloss (github.com/charmbracelet/lipgloss)

v2.0.5

Compare Source

Changelog


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on X, Discord, Slack, The Fediverse, Bluesky.

v2.0.4

Compare Source

Mini Crash Patch

Hi! This is a small patch to fix a writer-related panic. Thanks for using Lip Gloss!

Changelog

Fixed
Docs
Chore

The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on X, Discord, Slack, The Fediverse, Bluesky.

v2.0.3

Compare Source

Changelog

Fixed
Docs

The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on X, Discord, Slack, The Fediverse, Bluesky.

v2.0.2

Compare Source

Table patch

If you don't know, we made big improvements in table rendering recently shipped in v2.0.0.

@​MartinodF made a good job on improving it even further for tricky edge cases, in particular when content wrapping is enabled.

Changelog

Fixed

The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on X, Discord, Slack, The Fediverse, Bluesky.

v2.0.1

Compare Source

A small release to properly set style underline colors, as well as handling partial reads while querying the terminal.

Changelog

Fixed
Docs
Other stuff

The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on X, Discord, Slack, The Fediverse, Bluesky.

v2.0.0

Compare Source

lipgloss-v2-block

Do you think you can handle Lip Gloss v2?

We’re really excited for you to try Lip Gloss v2! Read on for new features and a guide to upgrading.

If you (or your LLM) just want the technical details, take a look at Upgrade Guide.

[!NOTE]
We take API changes seriously and strive to make the upgrade process as simple as possible. We believe the changes bring necessary improvements as well as pave the way for the future. If something feels way off, let us know.

What’s new?

The big changes are that Styles are now deterministic (λipgloss!) and you can be much more intentional with your inputs and outputs. Why does this matter?

Playing nicely with others

v2 gives you precise control over I/O. One of the issues we saw with the Lip Gloss and Bubble Tea v1s is that they could fight over the same inputs and outputs, producing lock-ups. The v2s now operate in lockstep.

Querying the right inputs and outputs

In v1, Lip Gloss defaulted to looking at stdin and stdout when downsampling colors and querying for the background color. This was not always necessarily what you wanted. For example, if your application was writing to stderr while redirecting stdout to a file, the program would erroneously think output was not a TTY and strip colors. Lip Gloss v2 gives you control over this.

Going beyond localhost

Did you know TUIs and CLIs can be served over the network? For example, Wish allows you to serve Bubble Tea and Lip Gloss over SSH. In these cases, you need to work with the input and output of the connected clients as opposed to stdin and stdout, which belong to the server. Lip Gloss v2 gives you flexibility around this in a more natural way.

🧋 Using Lip Gloss with Bubble Tea?

Make sure you get all the latest v2s as they’ve been designed to work together.

# Collect the whole set.
go get charm.land/bubbletea/v2
go get charm.land/bubbles/v2
go get charm.land/lipgloss/v2

🐇 Quick upgrade

If you don't have time for changes and just want to upgrade to Lip Gloss v2 as fast as possible? Here’s a quick guide:

Use the compat package

The compat package provides adaptive colors, complete colors, and complete adaptive colors:

import "charm.land/lipgloss/v2/compat"

// Before
color := lipgloss.AdaptiveColor{Light: "#f1f1f1", Dark: "#cccccc"}

// After
color := compat.AdaptiveColor{Light: lipgloss.Color("#f1f1f1"), Dark: lipgloss.Color("#cccccc")}

compat works by looking at stdin and stdout on a global basis. Want to change the inputs and outputs? Knock yourself out:

import (
	"charm.land/lipgloss/v2/compat"
	"github.com/charmbracelet/colorprofile"
)

func init() {
	// Let’s use stderr instead of stdout.
	compat.HasDarkBackground = lipgloss.HasDarkBackground(os.Stdin, os.Stderr)
	compat.Profile = colorprofile.Detect(os.Stderr, os.Environ())
}
Use the new Lip Gloss writer

If you’re using Bubble Tea with Lip Gloss you can skip this step. If you're using Lip Gloss in a standalone fashion, however, you'll want to use lipgloss.Println (and lipgloss.Printf and so on) when printing your output:

s := someStyle.Render("Fancy Lip Gloss Output")

// Before
fmt.Println(s)

// After
lipgloss.Println(s)

Why? Because lipgloss.Println will automatically downsample colors based on the environment.

That’s it!

Yep, you’re done. All this said, we encourage you to read on to get the full benefit of v2.

👀 What’s changing?

Only a couple main things that are changing in Lip Gloss v2:

  • Color downsampling in non-Bubble-Tea uses cases is now a manual proccess (don't worry, it's easy)
  • Background color detection and adaptive colors are manual, and intentional (but optional)
🪄 Downsampling colors with a writer

One of the best things about Lip Gloss is that it can automatically downsample colors to the best available profile, stripping colors (and ANSI) entirely when output is not a TTY.

If you're using Lip Gloss with Bubble Tea there's nothing to do here: downsampling is built into Bubble Tea v2. If you're not using Bubble Tea you now need to use a writer to downsample colors. Lip Gloss writers are a drop-in replacement for the usual functions found in the fmt package:

s := someStyle.Render("Hello!")

// Downsample and print to stdout.
lipgloss.Println(s)

// Render to a variable.
downsampled := lipgloss.Sprint(s)

// Print to stderr.
lipgloss.Fprint(os.Stderr, s)
🌛 Background color detection and adaptive colors

Rendering different colors depending on whether the terminal has a light or dark background is an awesome power. Lip Gloss v2 gives you more control over this progress. This especially matters when input and output are not stdin and stdout.

If that doesn’t matter to you and you're only working with stdout you skip this via compat above, though we encourage you to explore this new functionality.

With Bubble Tea

In Bubble Tea, request the background color, listen for a BackgroundColorMsg in your update, and respond accordingly.

// Query for the background color.
func (m model) Init() tea.Cmd {
	return tea.RequestBackgroundColor
}

// Listen for the response and initialize your styles accordigly.
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
	switch msg := msg.(type) {
	case tea.BackgroundColorMsg:
		// Initialize your styles now that you know the background color.
		m.styles = newStyles(msg.IsDark())
		return m, nil
	}
}

type styles {
    myHotStyle lipgloss.Style
}

func newStyles(bgIsDark bool) (s styles) {
	lightDark := lipgloss.LightDark(bgIsDark) // just a helper function
	return styles{
		myHotStyle := lipgloss.NewStyle().Foreground(lightDark("#f1f1f1", "#​333333"))
	}
}
Standalone

If you're not using Bubble Tea you simply can perform the query manually:

// Detect the background color. Notice we're writing to stderr.
hasDarkBG, err := lipgloss.HasDarkBackground(os.Stdin, os.Stderr)
if err != nil {
    log.Fatal("Oof:", err)
}

// Create a helper for choosing the appropriate color.
lightDark := lipgloss.LightDark(hasDarkBG)

// Declare some colors.
thisColor := lightDark("#C5ADF9", "#​864EFF")
thatColor := lightDark("#​37CD96", "#​22C78A")

// Render some styles.
a := lipgloss.NewStyle().Foreground(thisColor).Render("this")
b := lipgloss.NewStyle().Foreground(thatColor).Render("that")

// Print to stderr.
lipgloss.Fprintf(os.Stderr, "my fave colors are %s and %s...for now.", a, b)

🥕 Other stuff

Colors are now color.Color

lipgloss.Color() now produces an idiomatic color.Color, whereas before colors were type lipgloss.TerminalColor. Generally speaking, this is more of an implementation detail, but it’s worth noting the structural differences.

// Before
type TerminalColor interface{/* ... */}
type Color string

// After
func Color(string) color.Color
type RGBColor struct{R, G, B uint8}

func LightDark(isDark bool) LightDarkFunc
type LightDarkFunc func(light, dark color.Color) color.Color
func Complete(colorprofile.Profile) CompleteFunc
type CompleteFunc func(ansi, ansi256, truecolor color.Color) color.Color

Changelog

New!
  • b259725e46e9fbb2af6673d74f26917ed42df370: feat(blending): early return when steps <= num stops (#​566) (@​lrstanley)
  • 71dd8ee66ac1f4312844a792952789102513c9c5: feat(borders): initial border blend implementation (#​560) (@​lrstanley)
  • 2166ce88ec1cca66e8a820a86baafd7cfd34bcd0: feat(canvas): accept any type as layer content (@​aymanbagabas)
  • 0303864674b37235e99bc14cd4da17c409ec448e: feat(colors): refactor colors sub-package into root package (@​lrstanley)
  • 9c86c1f950fbfffd6c56a007de6bd3e61d67a1ea: feat(colors): switch from int to float64 for inputs (@​lrstanley)
  • 0334bb4562ca1f72a684c1c2a63c848ac21fffc6: feat(tree): support width and indenter styling (#​446) (@​dlvhdr)
  • 9a771f5a242df0acf862c7acd72124469eb4635a: feat: BlendLinear* -> Blend* (@​lrstanley)
  • 34443e82a7ddcbe37b9dc0d69b84385e400b8a5c: feat: add brightness example, misc example tweaks (@​lrstanley)
  • c95c5f3c5b27360d344bf82736a8ce9257aaf71e: feat: add hyperlink support (#​473) (@​aymanbagabas)
  • 5e542b8c69a0f20ea62b2caa422bbee5337fbb48: feat: add underline style and color (@​aymanbagabas)
  • d3032608aa74f458a7330e17cc304f1ebb5fa1b9: feat: add wrap implementation preserving styles and links (#​582) (@​aymanbagabas)
  • 7bf18447c8729839ca7e79aa3ba9aa00ecb8f963: feat: further simplify colors in examples (@​lrstanley)
  • 27a8cf99a81d1bd5ab875cd773ac8647320b02ba: feat: implement uv Drawable for Canvas and Layer (@​aymanbagabas)
  • c4c08fc4f8a107b00bc54407ad9094b9642dd103: feat: implement uv.Drawable for *Layer (#​607) (@​ayn2op)
  • 18b4bb86c515f93eede5720fe66b0d9ba83fa489: feat: initial implementation of color blending & brightness helpers (@​lrstanley)
  • 63610090044b782caa8ce8b1b53cc81b98264eaa: feat: update examples/layout to use colors.BlendLinear1D (@​lrstanley)
  • de4521b8baa33c49a96e9458e9d9213c7ba407bd: feat: update examples/list/sublist to use colors.BlendLinear1D (@​lrstanley)
  • 1b3716cc53b5cc29c2b1b0c655a684b797fef075: feat: use custom hex parsing for increased perf (@​lrstanley)
Fixed
  • 06ca257e382fa107afcfe147c9cda836b3cdb4be: fix(canvas): Hit method should return Layer ID as string instead of *Layer (@​aymanbagabas)
  • d1fa8790efbd70df8b0dd8bd139434f3ac6e063b: fix(canvas): handle misc edge cases (#​588) (@​lrstanley)
  • 7869489d8971e2e3a8de8e0a4a1e1dfe4895a352: fix(canvas): simplify Render handling (@​aymanbagabas)
  • 68f38bdee72b769ff9c137a4097d9e64d401b703: fix(ci): use local golangci config (@​aymanbagabas)
  • ff11224963a33f6043dfb3408e67c7fea7759f34: fix(color): update deprecated types (@​aymanbagabas)
  • 3f659a836c78f6ad31f5652571007cb4ab9d1eb8: fix(colors): update examples to use new method locations (@​lrstanley)
  • 3248589b24c9894694be6d1862817acb77e119cc: fix(layers): allow recursive rendering for layers that only contain children (#​589) (@​lrstanley)
  • 6c33b19c3f0a1e7d50ce9028ef4bda3ca631cd68: fix(lint): remove nolint:exhaustive comments and ignore var-naming rule for revive (@​aymanbagabas)
  • d267651963ad3ba740b30ecf394d7a5ef86704fc: fix(style): use alias for Underline type from ansi package (@​aymanbagabas)
  • 76690c6608346fc7ef09db388ee82feaa7920630: fix(table): fix wrong behavior of headers regarding margins (#​513) (@​andreynering)
  • 41ff0bf215ea2a444c5161d0bd7fa38b4a70af27: fix(terminal): switch to uv.NewCancelReader for Windows compatibility (@​aymanbagabas)
  • 5d69c0e790f24cbfaa94f8f8b2b64d1bb926c96d: fix: ensure we strip out \r\n from strings when getting lines (@​aymanbagabas)
  • 2e570c2690b61bac103e7eef9da917d1dfc6512d: fix: linear-2d example (@​lrstanley)
  • 0d6a022f7d075e14d61a755b3e9cab9d97519f21: fix: lint issues (@​aymanbagabas)
  • 832bc9d6b9d209e002bf1131938ffe7dbba07652: fix: prevent infinite loop with zero-width whitespace chars (#​108) (#​604) (@​calobozan)
  • 354e70d6d0762e6a54cfc45fe8d019d6087a4c00: fix: rename underline constants to be consistent with other style properties (@​raphamorim)
Docs
  • 60df47f8000b6cb5dfec46af37bceb2c9050bef0: docs(readme): cleanup badges (@​meowgorithm)
  • 881a1ffc54b6afb5f22ead143d10f8dce05e7e66: docs(readme): update art (@​meowgorithm)
  • ee74a03efa8363cf3b17ee7a128b9825c8f3791e: docs(readme): update footer art and copyright date (@​meowgorithm)
  • 8863cc06da67b8ef9f4b6f80c567738fa53bd090: docs(readme): update header image (@​meowgorithm)
  • 4e8ca2d9f045d6bca78ee0150420e26cda8bcccf: docs: add underline styles and colors caveats (@​aymanbagabas)
  • a8cfc26d7de7bdb335a8c7c2f0c8fc4f18ea8993: docs: add v2 upgrade and changes guide (#​611) (@​aymanbagabas)
  • 454007a0ad4e8b60afc1f6fdc3e3424e4d3a4c16: docs: update comments in for GetPaddingChar and GetMarginChar (@​aymanbagabas)
  • 95f30dbdc90cc409e8645de4bd2296a33ba37c70: docs: update mascot header image (@​aymanbagabas)
  • a06a847849dbd1726c72047a98ab8cce0f73a65f: docs: update readme in prep for v2 (#​613) (@​aymanbagabas)
Other stuff
  • 5ca0343ec7be2e85521e79734f4392cdb19e4949: Fix(table): BorderRow (#​514) (@​bashbunni)
  • f2d1864a58cd455ca118e04123feae177d7d2eef: Improve performance of maxRuneWidth (#​592) (@​clipperhouse)
  • 10c048e361129dd601eb6ff8c0c2458814291156: Merge v2-uv-canvas into v2-exp (@​aymanbagabas)
  • d02a007bb19e14f6bf351ed71a47beb6bee9cae3: ci: sync dependabot config (#​521) (@​charmcli)
  • 8708a8925b60c610e68b9aa6e509ebd513a8244e: ci: sync dependabot config (#​561) (@​charmcli)
  • 7d1b622c64d1a68cdc94b30864ae5ec3e6abc2dd: ci: sync dependabot config (#​572) (@​charmcli)
  • 19a4b99cb3bbbd2ab3079adc500faa1875da87e8: ci: sync golangci-lint config (@​aymanbagabas)
  • a6c079dc8a3fc6e68a00214a767627ec8447adb5: ci: sync golangci-lint config (@​aymanbagabas)
  • 350edde4903bcc2eee5a8ce1552dd90c3b89c125: ci: sync golangci-lint config (#​553) (@​github-actions[bot])
  • 1e3ee3483a907facd98ca0a56f6694a0e9365f26: ci: sync golangci-lint config (#​598) (@​github-actions[bot])
  • e729228ac14e63057e615a2241ce4303d59fef08: lint: fix lint for newer go versions (#​540) (@​andreynering)
  • 66093c8cf3b79596597c1e39fd4c67a954010fb3: perf: remove allocations from getFirstRuneAsString (#​578) (@​clipperhouse)
  • ad876c4132d61951d091a1a535c27237f6a90ad6: refactor: new Canvas, Compositor, and Layer API (#​591) (@​aymanbagabas)
  • 3aae2866142214f5b8ce9cbfc1939645928dcb8f: refactor: update imports to use charm.land domain (@​aymanbagabas)

🌈 Feedback

That's a wrap! Feel free to reach out, ask questions, and let us know how it's going. We'd love to know what you think.


Part of Charm.

The Charm logo

Charm热爱开源 • Charm loves open source • نحنُ نحب المصادر المفتوحة


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate

renovate Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: go.sum
Command failed: go get -t ./...
go: github.com/charmbracelet/lipgloss/v2@v2.0.5: parsing go.mod:
	module declares its path as: charm.land/lipgloss/v2
	        but was required as: github.com/charmbracelet/lipgloss/v2

@elysia-best elysia-best added AUTO Automatically created by robots/AIs dependencies labels Jul 8, 2026
@xrgzs xrgzs added the invalid Invalid Content/Cannot Reproduce label Jul 9, 2026
@renovate
renovate Bot force-pushed the renovate/github.com-charmbracelet-lipgloss-2.x branch from 4d3f58b to 53ef58c Compare July 12, 2026 09:51
@renovate
renovate Bot force-pushed the renovate/github.com-charmbracelet-lipgloss-2.x branch from 53ef58c to 4047dfb Compare July 20, 2026 16:29
@renovate
renovate Bot force-pushed the renovate/github.com-charmbracelet-lipgloss-2.x branch from 4047dfb to e110b89 Compare July 22, 2026 09:59

@pikachuren pikachuren left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏 感谢贡献

感谢 @app/renovate 提交此自动依赖更新 PR!我已完成代码评审,以下是评审结果。


🤖 AI 自动审核声明

本评审报告由 AI 自动生成,当前使用 Claude Opus 5 模型进行分析,部分复杂场景可能辅助使用 ChatGPT、DeepSeek 等模型进行交叉验证。

⚠️ AI 分析结果仅供参考,可能存在误判或遗漏。如您发现任何问题或有不同意见,欢迎随时提出讨论和纠正。

⚠️ 重要提醒:即使 AI 评审认为代码质量良好且建议合并,最终是否合并仍需由项目维护者进行人工判定。项目维护者会综合考虑代码质量、项目规划、技术方向、团队资源等多方面因素做出决策。


📖 PR背景与需求

PR标题:fix(deps): update module github.com/charmbracelet/lipgloss to v2

依赖更新类型:主版本升级(Major Version Update)

需求说明
Renovate Bot 自动创建的依赖更新 PR,将 github.com/charmbracelet/lipgloss 从 v1.1.0 升级到 v2.0.5(主版本升级)。

预期目标

  • 使用 lipgloss v2 的新功能和改进
  • 修复 v1 中存在的 bug
  • 跟进上游库的最新稳定版本

📋 问题摘要

  • ⚠️ 破坏性变更风险:主版本升级包含不兼容的 API 变更(⚠️ 高风险)
  • ⚠️ 不完整迁移:同时保留 v1 和 v2 两个版本,依赖冗余(⚠️ 重要)
  • ⚠️ 缺少兼容性验证:未检查代码是否需要适配新 API(⚠️ 关键)
  • 💡 需要测试验证:必须运行完整测试套件确认无回归

📂 逐文件分析

go.mod

改动意图
将 lipgloss 依赖从 v1.1.0 升级到 v2.0.5。

代码修改逻辑

-	github.com/charmbracelet/lipgloss v1.1.0
+	github.com/charmbracelet/lipgloss/v2 v2.0.5

在 Go modules 中,主版本 v2+ 需要在模块路径中包含版本后缀(/v2),因此这是一个模块路径变更,而不是简单的版本号升级。

合理性评估

优点

  1. 符合 Go modules 规范:正确使用了 /v2 路径后缀
  2. 版本选择合理:v2.0.5 是 v2 系列的稳定版本,包含多个 bug 修复
  3. 上游质量良好:lipgloss v2 经过充分测试,由 Charm 团队维护

⚠️ 重要疑问

  1. 依赖冗余问题⚠️ 关键)

    • 当前 go.mod 中可能同时保留了 v1 和 v2 两个版本
    • 这会导致编译后的二进制文件包含两份 lipgloss 代码,显著增大体积
    • 需要检查 go.mod 的完整内容和 go.sum,确认是否真的存在冗余
  2. 代码兼容性问题⚠️ 高风险)

    • lipgloss v2 包含破坏性 API 变更,根据官方 changelog:

      • 颜色系统重构:lipgloss.Color 现在返回 color.Color 接口
      • 自适应颜色变更:AdaptiveColor 类型被移除,需使用 compat 包或新 API
      • 背景色检测变更:需手动调用 HasDarkBackground() 或使用 compat
      • 颜色降采样变更:非 Bubble Tea 场景需使用 lipgloss.Println() 等 writer 函数
    • 必须检查的代码位置

      • 所有 import "github.com/charmbracelet/lipgloss" 需改为 lipgloss/v2
      • 所有使用 lipgloss.AdaptiveColor 的地方需要迁移
      • 所有使用 fmt.Println(style.Render(...)) 的地方需改为 lipgloss.Println(...)
  3. 迁移策略不明确

    • 是完全迁移到 v2?(推荐)
    • 还是渐进式迁移?(需要明确计划)
    • 还是意外引入?(需要回退)

明确问题

  1. 缺少兼容性验证

    • PR 描述中没有提到是否检查了代码兼容性
    • 没有提到是否运行了测试套件
    • 没有提到是否查阅了 v2 的 breaking changes
  2. 缺少迁移说明

    • 没有说明哪些代码需要修改
    • 没有提供迁移 checklist
    • 没有说明是否使用了 compat 包作为过渡方案

🎯 总体评价

功能性⚠️⚠️⚠️ - 主版本升级,需验证兼容性
安全性:⭐⭐⭐⭐ - lipgloss 不涉及安全关键逻辑,上游可信
代码质量⚠️⚠️⚠️ - 不完整的迁移,可能导致编译失败或运行时错误
实现方案⚠️⚠️ - 需要制定完整的迁移方案

建议操作

  • ✅ Approve(建议合并)
  • 🔄 Request Changes(需要修改)
  • ❌ Close(建议关闭)

理由

此 PR 是一个主版本升级,包含破坏性 API 变更,需要谨慎处理。当前状态存在以下关键问题:

  1. 不确定是否完成了代码迁移

    • 仅修改了 go.mod,但没有看到任何代码层面的修改
    • lipgloss v2 的 API 变更需要修改所有使用 lipgloss 的代码
    • 如果没有修改代码,这个 PR 肯定会导致编译失败
  2. 可能存在依赖冗余

    • 需要确认 v1 是否已被完全移除
    • 运行 go mod tidy 并检查 go.mod 中是否还有 v1
  3. 缺少测试验证

    • 主版本升级必须运行完整的测试套件
    • 需要确认所有功能正常,无回归

📝 详细建议

必须完成的步骤(按顺序):

1. 调查当前代码的 lipgloss 使用情况

# 搜索所有导入 lipgloss 的文件
grep -r "github.com/charmbracelet/lipgloss" . --include="*.go"

# 搜索所有使用 AdaptiveColor 的地方
grep -r "AdaptiveColor" . --include="*.go"

# 搜索所有使用 fmt.Println 打印样式的地方(需改为 lipgloss.Println)
grep -r "fmt.Println.*Render" . --include="*.go"

2. 决定迁移策略

方案 A:完全迁移到 v2(✅ 推荐)

优点:

  • 清理了依赖,减小二进制体积
  • 使用最新功能和 bug 修复
  • 长期维护更简单

步骤:

  1. 修改所有 import 语句:import "github.com/charmbracelet/lipgloss/v2"
  2. 根据 v2 升级指南 修改代码:
    • 使用 compat 包替换 AdaptiveColor
    • 使用 lipgloss.Println() 替换 fmt.Println()(如果不使用 Bubble Tea)
  3. 运行 go mod tidy
  4. 运行完整测试:go test ./...
  5. 手动测试 TUI 功能,确认样式渲染正常

方案 B:保持 v1

如果迁移成本过高或 v2 有不可接受的问题:

  1. 关闭此 PR
  2. renovate.json 中配置忽略 lipgloss v2:
    {
      "packageRules": [
        {
          "matchPackageNames": ["github.com/charmbracelet/lipgloss"],
          "allowedVersions": "< 2.0.0"
        }
      ]
    }

方案 C:渐进式迁移

如果项目较大,希望分步迁移:

  1. 制定明确的迁移计划和时间表
  2. 先引入 v2,使用 compat 包确保兼容性
  3. 逐步重构代码,最终完全迁移到 v2 原生 API
  4. 但要注意:同时维护两个版本会增加二进制体积,应尽快完成迁移

3. 查阅官方迁移指南

必读文档

关键变更摘要

v1 API v2 API 说明
lipgloss.AdaptiveColor{Light: "...", Dark: "..."} compat.AdaptiveColor{Light: lipgloss.Color("..."), Dark: lipgloss.Color("...")}lipgloss.LightDark(isDark) 自适应颜色需使用 compat 包或新 API
fmt.Println(style.Render("text")) lipgloss.Println(style.Render("text")) 非 Bubble Tea 场景需使用 lipgloss writer
lipgloss.Color("#ff0000") lipgloss.Color("#ff0000") 现在返回 color.Color 接口
自动背景色检测 lipgloss.HasDarkBackground(os.Stdin, os.Stdout) 需手动检测或使用 compat 包

4. 运行测试并验证

# 确保依赖正确
go mod tidy

# 运行单元测试
go test ./... -v

# 运行集成测试(如果有)
go test ./... -tags=integration

# 编译检查
go build ./...

# 手动测试 TUI 功能
# 启动应用,检查:
# - 样式渲染是否正常
# - 颜色是否正确(浅色/深色主题)
# - 是否有崩溃或错误

💡 快速修复建议(如果选择完全迁移)

示例:使用 compat 包作为过渡方案

如果你的代码中使用了 AdaptiveColor,最简单的迁移方式是使用 compat 包:

// Before (v1)
import "github.com/charmbracelet/lipgloss"

var myColor = lipgloss.AdaptiveColor{Light: "#f1f1f1", Dark: "#333333"}

// After (v2, 使用 compat 包)
import (
    "github.com/charmbracelet/lipgloss/v2"
    "github.com/charmbracelet/lipgloss/v2/compat"
)

var myColor = compat.AdaptiveColor{
    Light: lipgloss.Color("#f1f1f1"), 
    Dark: lipgloss.Color("#333333"),
}

示例:修改输出方式

如果你不使用 Bubble Tea,需要改用 lipgloss writer:

// Before (v1)
import (
    "fmt"
    "github.com/charmbracelet/lipgloss"
)

s := someStyle.Render("Hello!")
fmt.Println(s)

// After (v2)
import "github.com/charmbracelet/lipgloss/v2"

s := someStyle.Render("Hello!")
lipgloss.Println(s)  // 自动处理颜色降采样

🔍 需要回答的问题

在合并此 PR 之前,请确认以下问题:

  1. 是否查阅了 lipgloss v2 的升级指南和 breaking changes?
  2. 是否修改了所有使用 lipgloss 的代码以适配 v2 API?
  3. 是否运行了 go mod tidy 并确认 v1 已被移除?
  4. 是否运行了完整的测试套件并通过?
  5. 是否手动测试了 TUI 功能,确认样式渲染正常?
  6. 是否检查了编译后的二进制文件大小,确认无依赖冗余?

如果以上任何一项为 ❌,此 PR 不应合并


📚 参考资料


总结

这是一个需要谨慎处理的主版本升级 PR。建议:

  1. 暂不合并,先完成代码迁移工作
  2. 制定迁移计划,决定使用哪种方案(完全迁移/保持 v1/渐进迁移)
  3. 彻底测试,确保无回归
  4. 更新 PR 描述,说明迁移工作的进展和测试结果

如果需要帮助迁移代码,请随时提问!我可以协助分析具体的代码修改需求。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AUTO Automatically created by robots/AIs dependencies invalid Invalid Content/Cannot Reproduce

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants